<template>
    <v-container>
        <div>
            <quill-editor v-model="content" :options="editorOptions"></quill-editor>
        </div>

        <v-row dense no-gutters>
            <v-col>
                <v-btn depressed color="primary" class="mr-2" @click="save" :loading="saving">保存</v-btn>
            </v-col>
        </v-row>
    </v-container>
</template>

<script>

export default {
    data: () => ({
        content: '', // 绑定富文本编辑器的内容
        editorOptions: {
            height: '600px'
        },
        saving: false
    }),
    created() {
        this.load();
    },
    methods: {
        load() {
            axios.get(`/app/setting/about`).then((response) => {
                if(response.data.code == 0) {
                    console.log(this.content)
                    this.content = response.data.data ?  response.data.data : '';
                }
            })
                .catch(function () {})
                .then(function () {
                });
        },

        save() {

            this.saving = true;
            const that = this;
            axios.post(`/app/setting/about`, {value: this.content}).then((response) => {
                this.$toast.open({
                    message: response.data.msg,
                    type: response.data.code == 0 ? 'success' : 'error',
                    position: 'top-right',
                });
            })
                .catch(function () {})
                .then(function () {
                    that.saving = false;
                });
        }
    }
}
</script>
<style>
.quill-editor {
    height: 600px; /* 设置编辑器高度 */
}
</style>
